//
//  HosListCell.m
//  Doctor1.0
//
//  Created by mk on 15/11/20.
//  Copyright (c) 2015年 cocoa-mk. All rights reserved.
//

#import "HosListCell.h"

@implementation HosListCell

- (void)awakeFromNib
{
    // Initialization code
    
    for (NSLayoutConstraint *constraints in [labdesc constraints])
    {
        if (constraints.firstItem == labdesc && constraints.firstAttribute == NSLayoutAttributeWidth)
        {
            constraints.constant = appScreenWidth-20;
            break;
        }
    }

    
    imageAvatar.layer.cornerRadius = imageAvatar.width/2;
    imageAvatar.clipsToBounds = YES;
    
    btnApptButton.layer.cornerRadius = 8;
    btnApptButton.clipsToBounds = YES;
}


-(void)fillDoctorDataWith:(Doctor *)doctor
{
    [imageAvatar sd_setImageWithURL:doctor.imageUrl placeholderImage:loadDoctorImageDefaule];
 
    labname.text = doctor.name;
    if(doctor.mTitle.length>0 && doctor.aTitle.length>0)
    {
        labtitle.text = [NSString stringWithFormat:@"%@/%@",doctor.mTitle,doctor.aTitle];
    }else
    {
        labtitle.text = @"";
    }
    if (doctor.desc.length>0)
        labdesc.text = [NSString stringWithFormat:@"擅长: %@",doctor.desc];
    else
        labdesc.text = @"";

    btnApptButton.hidden = ([doctor.isContracted isEqualToString:@"0"]);
}

-(IBAction)btnClick:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(selectDoctorWith:)])
    {
        [self.delegate selectDoctorWith:self];
    }

}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end











